using System.Transactions;
using StockholmsStad.Data.Context;
using StockholmsStad.Data.Interfaces;
using System;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;

namespace StockholmsStad.Data.Test
{
    public abstract class TestUnitBase
    {
        protected static AgentFactory AgentFactory
        {
            get { return new AgentFactory(); }
        }

        protected IDataContext context { get; private set; }

        public void BeginTransaction()
        {
            context = new ContextFactory().GetContext(true, UserRole.SysAdmin);
        }

        [Obsolete("Ska endast användas för epost-test")]
        public void EndTransaction(bool completeTransaction)
        {
            if(completeTransaction)
                context.TransactionComplete();

            context.Dispose();
        }

        public void EndTransaction()
        {
            context.Dispose();
        }
    }
}